//
//  OrderFromModel.m
//  JackDeve
//
//  Created by 王奎卿 on 2017/5/10.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "OrderFromModel.h"
#import <AFNetworking.h>
#import "OrderModel.h"

OrderFromModel *orderData = nil;
@implementation OrderFromModel

- (void)getOrderData:(NSString *)url
{
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
    //  设置解析器
    manager.requestSerializer = [[AFJSONRequestSerializer alloc]init];
    
    [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dic = (NSDictionary *)responseObject;
        
        NSMutableArray *array = [NSMutableArray arrayWithArray:[dic objectForKey:@"data"]];
        
        NSMutableArray *orderArray = [NSMutableArray array];
        
//        NSMutableArray *dataArr = [NSMutableArray array];
        
        for (NSDictionary *ddd in array)
        {
            OrderModel *model = [[OrderModel alloc]init];
            
            [model setValuesForKeysWithDictionary:ddd];
            
            [orderArray addObject:model];
        }
        
        [self.delegate postOrderJson:orderArray];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}

@end
